﻿using SwenAssigment.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SwenAssigment
{
    public partial class PasswordRequest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            ClientScriptManager cs = Page.ClientScript;
            if (Session["login"] != null)
            {
                String username = ((UserClass)Session["login"]).UserName;
                //SecureFunction.hashvalue
                if (JcUser.UpdatePassword(username, SecureFunction.hashvalue(TextBox1.Text), SecureFunction.hashvalue(TextBox2.Text)) == "Updated")
                {
                    cs.RegisterStartupScript(this.GetType(), "PopupScript", "alert('Updated!');", true);
                    TextBox1.Text = "";
                    TextBox2.Text = "";
                    TextBox3.Text = "";
                }
                else
                {
                    cs.RegisterStartupScript(this.GetType(), "PopupScript", "alert('Fail');", true);
                }
            }
        }
    }
}